package WaiBao;

import java.util.Arrays;

public class ZhangTao {
    public static void main(String[] args) {
        String[] name= {"李大鹏(班长)", "王富贵(副班长)", "小李(学习委员)", "王龙耀(文艺委员)", "张小海", "张文文", "徐宁宁", "旭之光", "李道听", "王图说", "张晓", "李文龙",
                "刘欢", "李道琼", "王子民", "张静文", "张晓", "李心艾", "核桃", "空而妙", "铆钉", "砖头", "房东", "戴雨桐", "林泽凯", "林浩东", "张无忌", "张三丰",
                "周星驰", "张涛(学生)"};//考生本人:张涛(学生)
        int[] age = {20, 21,18,20,20, 19, 21,20,18, 22,19,19, 21, 19, 21,20, 21, 19, 20, 19, 19,21, 21, 21, 20, 23, 18,22,20, 21};//考生年龄：21岁

        double[] yangyu1 = {77, 72, 87, 90, 79, 69, 78, 89, 80, 80, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 84, 78, 95};
        double[] yangyu2 = {74, 85, 90, 76, 88, 77, 78, 69, 90, 70, 90, 77, 66, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 88, 76, 86, 88, 65, 84, 96};
        double[] yangyu3 = {86, 76, 84, 85, 74, 66, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 73, 87, 97};

        double qianyu1;//代表每个学生的总分
        double qianyu2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            qianyu1 = yangyu1[i] +yangyu2[i] + yangyu3[i];
//            qianyu2 = (qianyu1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + qianyu1);
//            System.out.println(name[i] + "的平均分为:" + qianyu2);
//        }


        double yajing1 = 0,yajing2 = 0;
        double[] quanquan = new double[30];
//        for (int i = 0; i < 30; i++) {
//            yajing1 = yangyu1[i] +yangyu2[i] + yangyu3[i];
//            yajing2 = (yajing1 * 1.0) / 3;
//            quanquan[i] = yajing2;
//        }
//
//        for (int i = 0; i < quanquan.length - 1; i++) {
//            for (int j = 0; j < quanquan.length - i - 1; j++) {
//                if (quanquan[j] <quanquan[j + 1]) {
//                    double tep =quanquan[j];
//                    quanquan[j] = quanquan[j + 1];
//                    quanquan[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(quanquan[i]);
//        }


        double banma1 = 0, banma2 = 0, banma3 = 0;//计算每门课的平均分
        double sion1 = 0, sion2 = 0,sion3 = 0;//计算每门课标准差
        double tiger1 = 0,tiger2 = 0,tiger3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <yangyu1.length; i++) {
            he += yangyu1[i];
        }
        banma1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + banma1);
        double Sum = 0;
        for (int i = 0; i < yangyu2.length; i++) {
            Sum += yangyu2[i];
        }
        banma2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + banma2);
        double sum = 0;
        for (int i = 0; i < yangyu3.length; i++) {
            sum += yangyu3[i];
        }
        banma3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + banma3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < yangyu1.length; i++) {
            c1 += (yangyu1[i] -banma1) * (yangyu1[i] - banma1);
        }
        sion1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + sion1);
        for (int i = 0; i < yangyu2.length; i++) {
            c2 += (yangyu2[i] - banma2) * (yangyu2[i] -banma2);
        }
        sion2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + sion2);

        for (int i = 0; i <yangyu3.length; i++) {
            c3 += (yangyu3[i] - banma3) * (yangyu3[i] - banma3);
        }
        sion3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + sion3);
////
//
//
        Arrays.sort(yangyu1);
        Arrays.sort(yangyu2);
        Arrays.sort(yangyu3);
        tiger1 = (yangyu1[14] + yangyu2[15]) * 1.0 / 2;
        tiger2 = (yangyu2[14] + yangyu2[15]) * 1.0 / 2;
        tiger3 = (yangyu3[14] + yangyu3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + tiger1);
        System.out.println("物理化学的中位数为:" + tiger2);
        System.out.println("电子与电工技术的中位数为:" +tiger3);



    }
}
